﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.Data;
using System.Data.SqlClient;
using System.Collections;

namespace B2B.Models
{
    public class SP_ThemSendContact
    {
        string emailNguoiGui;

        public string EmailNguoiGui
        {
            get { return emailNguoiGui; }
            set { emailNguoiGui = value; }
        }
        string emailNguoiNhan;

        public string EmailNguoiNhan
        {
            get { return emailNguoiNhan; }
            set { emailNguoiNhan = value; }
        }
        string chuDe;

        public string ChuDe
        {
            get { return chuDe; }
            set { chuDe = value; }
        }
        string noiDung;

        public string NoiDung
        {
            get { return noiDung; }
            set { noiDung = value; }
        }
        string hinhAnh;

        public string HinhAnh
        {
            get { return hinhAnh; }
            set { hinhAnh = value; }
        }

        private string maSP;

        public string MaSP
        {
            get { return maSP; }
            set { maSP = value; }
        }
        
        public int ThemSendEmailContact(SP_ThemSendContact emailContact, string hinhAnh, string link)
        {
            SqlConnection conn = KetNoi.Connection();
            SqlCommand cmd = new SqlCommand("SP_THEMEMAILCONTACT", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@nguoiGui", emailContact.emailNguoiGui);
            cmd.Parameters.AddWithValue("@NguoiNhan", emailContact.emailNguoiNhan);
            cmd.Parameters.AddWithValue("@ChuDe", emailContact.ChuDe);
            cmd.Parameters.AddWithValue("@NoiDung", emailContact.NoiDung);
            cmd.Parameters.AddWithValue("@HinhAnh", emailContact.hinhAnh);
            cmd.Parameters.AddWithValue("@Link", link);
            cmd.Parameters.AddWithValue("@MaSP", emailContact.MaSP);
            conn.Open();
            int kq = cmd.ExecuteNonQuery();
            conn.Close();
            return kq;
        }

        public int XoaEmailContact(int maEmail)
        {
            SqlConnection conn = KetNoi.Connection();
            SqlCommand cmd = new SqlCommand("SP_THEMEMAILCONTACT", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@maEmailContact", maEmail);
            conn.Open();
            int kq = cmd.ExecuteNonQuery();
            conn.Close();
            return kq;
        }
    }
}